package com.css.zfzx.fwsjcj.modules.structure.repository;

import com.css.zfzx.fwsjcj.commen.util.Constant;
import com.css.zfzx.fwsjcj.modules.structure.entity.FwStructureFormEntity;
import com.css.zfzx.fwsjcj.modules.structure.entity.FwWideStructureEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author leon
 * @Title: FwWideStructureRepository
 * @Description: 空旷结构
 * @date 2020/6/4 14:52
 */
@Repository
public interface FwWideStructureRepository extends JpaRepository<FwWideStructureEntity, String>, JpaSpecificationExecutor<FwWideStructureEntity>,
        QuerydslPredicateExecutor<FwWideStructureEntity> {
    FwWideStructureEntity findByWideStructureNumAndDelFlag(String wideStructureNum,String delflag);

    @Modifying
    @Query( nativeQuery = true, value = "update fw_wide_structure set detail_file =:fileId where id =:formId")
    void updateFile(@Param("formId") String formId, @Param("fileId") String fileId);

    /**
     * 查询在idList中数据
     */
    //@Query(nativeQuery = true, value = "select * from fw_wide_structure where del_flag =" + Constant.DEL_NO + " and id in :idList")
    @Query(nativeQuery = true, value = "select * from fw_wide_structure where id in :idList")
    List<FwWideStructureEntity> findInIdList(@Param("idList") List<String> idList);
}
